<?php

namespace App\Listeners;

use App\Events\Logined;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use \Carbon\Carbon;
class RecordUserLoginLog implements ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  Logined  $event
     * @return void
     */
    public function handle(Logined $event)
    {
        $user = $event->getUser();
        $ip = $event->getIp();
        \DB::table('login_logs')->insert([
            'user_id' => $user->id,
            'ip' => $ip,
            'created_at' => Carbon::now(),
            'updated_at' => Carbon::now()
        ]);
    }
}
